package model

import "fmt"

func TypeJudge(items ...interface{}) {
	for index, v := range items {
		//获取值的类型
		switch v.(type) {
		case bool:
			fmt.Printf("第%d个参数是bool类型，值是%v", index, v)
		case float32:
			fmt.Printf("第%d个参数是 float32 类型，值是%v", index, v)
		case float64:
			fmt.Printf("第%d个参数是 float32 类型，值是%v", index, v)
		case int, int32, int64, int8:
			fmt.Printf("第%d个参数是 int 类型，值是%v", index, v)
		case string:
			fmt.Printf("第%d个参数是 string 类型，值是%v", index, v)
		case Student:
			fmt.Printf("第%d个参数是 student 类型，值是%v", index, v)
		case *Student:
			fmt.Printf("第%d个参数是 *student 类型，值是%v", index, v)
		default:
			fmt.Printf("第%d个参数是 不确定类型，值是%v", index, v)
		}
	}
}

func TypeJudgeTest() {
	var n1 float64 = 1.2
	var n2 float32 = 1.2
	var n3 int32 = 12
	var n4 string = "tom"
	n5 := 12
	TypeJudge(n1, n2, n3, n4, n5, Student{}, &Student{})
}
